﻿<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>USER CENTER</title>
		<%@ include file="/share/include.jsp" %>
		<!-- <script src="js/jquery.min.js"></script> -->
   		 <meta name="viewport" content="width=device-width, initial-scale=1">
		 <script type="application/x-javascript"> 
			addEventListener("load", function() { 
				setTimeout(hideURLbar, 0); 
			}, false); 
			function hideURLbar(){ 
				window.scrollTo(0,1); 
			} 
		</script>
		<script type="text/javascript">
			$(function(){
				$('.close').click(function(){
					$('.contact-bottom-grids').hide();
					$('#orderId').val('');
					$('#orderMoney').val('');
					$('#orderHasPayMoney').val('');
					$('#orderFailsPayMoney').val('');
					$('#orderThisMoney').val('');
					//设置缴付信息的值
					$('#orderNumber').val('');
					$('#itemAmt').val('');
					$('#allAmt').val('');
				});
				
				//表单提交前 验证 表单
		        var demo = $("#userPaymentForm").Validform({
					btnSubmit : "#btn_sub",
					tiptype : function(msg,o,cssctl){
						//msg：提示信息;
						//o:{obj:*,type:*,curform:*}, obj指向的是当前验证的表单元素（或表单对象），type指示提示的状态，值为1、2、3、4， 1：正在检测/提交数据，2：通过验证，3：验证失败，4：提示ignore状态, curform为当前form对象;
						//cssctl:内置的提示信息样式控制函数，该函数需传入两个参数：显示提示信息的对象 和 当前提示的状态（既形参o中的type）;
						if(!o.obj.is("form")){//验证表单元素时o.obj为该表单元素，全部验证通过提交表单时o.obj为该表单对象;
							var objtip=o.obj.siblings(".Validform_checktip");
							cssctl(objtip,o.type);
							objtip.text(msg);
						}else{
							var objtip=o.obj.find("#msgdemo");
							cssctl(objtip,o.type);
							objtip.text(msg);
						}
					},
					ajaxPost:true,//ajax异步提交表单
					url:'${root }/control/order/orderItemController/userPayment.do',
					beforeCheck:function(curform){
						 
					 },
					 beforeSubmit:function(data){
						 
					 },callback:function(data){
					 	//alert(data.info);
					 	if(data.status == 'y' && data.info.length == 14){
					 		$('.contact-bottom-grids').hide();
					 		artDalog('确认订单金额提示','success!','${root}/control/order/orderItemController/userOrderExecutionList.do?orderUserId=${userSession.userId}');
					 	}else{
					 		artDalog('确认订单金额提示','error!', null);
					 	}
					 }
				});
				//设置验证成功后的提示信息
				demo.tipmsg.r = 'Through verification!';
			});
			function userPayment(id,orderMoney,orderHasPayMoney,orderFailsPayMoney,orderThisMoney){
				$('#orderId').val(id);
				$('#orderMoney').val(orderMoney);
				if(orderHasPayMoney == null || orderHasPayMoney == ''){
					orderHasPayMoney = '0.00';
				}
				$('#orderHasPayMoney').val(orderHasPayMoney);
				$('#orderFailsPayMoney').val(orderFailsPayMoney);
				$('#orderThisMoney').val(orderThisMoney);
				$('.contact-bottom-grids').show();
				//设置缴付信息的值
				$('#orderNumber').val('O'+id);
				$('#itemAmt').val(orderThisMoney);
				$('#allAmt').val(orderThisMoney);
			}
			
			function editStatus(id){
		      	art.dialog({
					width: 250,
					height: 100,
					fixed: true,
				    padding: 0,
				    title: "提示",
				    content: "是否确认订单<font style='color:red'>"+id+"</font>已完成？",
				    lock: true,
				    button: [{
					    name: "确定",
					    callback: function () {
					    	$.ajax({
								 url: "${root}/control/order/orderItemController/userConfirmOrder.do?orderId="+id,
								 data: {
								 	
								 },
								 type: "post",
								 success: function(data){
						        	if(data=="true"){
						        		var url = '${root }/control/order/orderItemController/userOrderCompleteList.do?orderUserId=${userSession.userId}';
										/* var param = $('#searchForm').serialize();
										url = url+param; */
						        		artDalog("提示","确认完成订单 <font style='color:red'>"+id+"</font> 成功",url);
						        		//search("searchForm");
						        	}else{
						        		artDalog("错误信息","订单 <font style='color:red'>"+id+"</font> 不存在，无法确认完成！",null);
						        	}
						      	}
						   	});
					    },
				        focus: true
				     },
				     {
				        name: "取消"
				     }]
				});
		      }
		      
		      //用户删除订单
			function deletedOrder(id){
				art.dialog({
					width: 250,
					height: 100,
					fixed: true,
				    padding: 0,
				    title: "提示",
				    content: "是否确认删除订单<font style='color:red'>"+id+"</font>？",
				    lock: true,
				    button: [{
					    name: "确定",
					    callback: function () {
					    	$.ajax({
								 url: "${root}/control/order/orderItemController/userDeletedOrder.do?orderId="+id,
								 data: {
								 	
								 },
								 type: "post",
								 success: function(data){
						        	if(data=="true"){
						        		var url = '${root }/control/order/orderItemController/userOrderExecutionList.do?orderUserId=${userSession.userId}';
						        		artDalog("提示","删除订单 <font style='color:red'>"+id+"</font> 成功",url);
						        	}else{
						        		artDalog("错误信息","订单 <font style='color:red'>"+id+"</font> 不存在，无法删除！",null);
						        	}
						      	}
						   	});
					    },
				        focus: true
				     },
				     {
				        name: "取消"
				     }]
				});
			}
			
			 //用户删除订单
			function userApplyRefund(id){
				art.dialog({
					width: 250,
					height: 100,
					fixed: true,
				    padding: 0,
				    title: "提示",
				    content: "是否确认订单<font style='color:red'>"+id+"</font> 申请退款？",
				    lock: true,
				    button: [{
					    name: "确定",
					    callback: function () {
					    	$.ajax({
								 url: "${root}/control/order/orderItemController/userApplyRefund.do?orderId="+id,
								 data: {
								 	
								 },
								 type: "post",
								 success: function(data){
						        	if(data=="true"){
						        		var url = '${root }/control/order/orderItemController/userOrderExecutionList.do?orderUserId=${userSession.userId}';
						        		artDalog("提示","订单 <font style='color:red'>"+id+"</font> 申请退款成功",url);
						        	}else{
						        		artDalog("错误信息","订单 <font style='color:red'>"+id+"</font> 不存在，无法退款！",null);
						        	}
						      	}
						   	});
					    },
				        focus: true
				     },
				     {
				        name: "取消"
				     }]
				});
			}
			
			/**
			*确认退款成功
			**/
			function userConfirmRefund(id){
				art.dialog({
					width: 250,
					height: 100,
					fixed: true,
				    padding: 0,
				    title: "提示",
				    content: "是否确认订单<font style='color:red'>"+id+"</font> 退款成功？",
				    lock: true,
				    button: [{
					    name: "确定",
					    callback: function () {
					    	$.ajax({
								 url: "${root}/control/order/orderItemController/userConfirmRefund.do?orderId="+id,
								 data: {
								 	
								 },
								 type: "post",
								 success: function(data){
						        	if(data=="true"){
						        		var url = '${root }/control/order/orderItemController/userOrderCompleteList.do?orderUserId=${userSession.userId}';
						        		artDalog("提示","确认订单 <font style='color:red'>"+id+"</font> 退款状态成功",url);
						        	}else{
						        		artDalog("错误信息","订单 <font style='color:red'>"+id+"</font> 不存在，无法确认退款状态！",null);
						        	}
						      	}
						   	});
					    },
				        focus: true
				     },
				     {
				        name: "取消"
				     }]
				});
			}
		</script>
	</head>
	<body>
		<!-- container -->
		<!-- header -->
		<div class="header">
			<%@ include file="/control/jsp/layout/header.jsp" %>
			<!-- /bottom-header -->
		</div>
		<!-- header -->
		<!--- top-nav -->
			<%@ include file="/control/jsp/layout/userMenu.jsp" %>
		<!--- top-nav -->
		<!-- Product-Details-page -->
		<div class="details-page">
			<div class="content details-page">
				<div class="product-details">
					<div class="container">
						<div class="details-left" style="width: 100%;">
						    <h4 style="color:red;"><img style="padding: 10px;" src="${root}/images/bx.gif" />执行中订单</h4>
							<table class="list_order" border="0" align="center" cellpadding="0" cellspacing="2">
							  <thead>
								<tr style="height:40px;">
								  <th>订单号</th>
								  <th>案例</th>
								  <th>商家名称</th>
								  <th>商家联系方式</th>
								  <th>总金额</th>
								  <th>已付款</th>
								  <th>未付款</th>
								  <th>操作</th>
								</tr>
							  </thead>
							  <tbody style="text-align: center;">
							 <c:if test="${not empty pageView.records }">
							  	<c:forEach items="${pageView.records }" var="order">
							  	        <tr style="height: 20px;"></tr>
									  	<tr style="height: 80px;">
										  <td>
										  	<a href="${root }/control/order/orderItemController/displayOrderDetail.do?orderId=${order.orderId }&orderUserId=${order.orderUserId }">${fn:escapeXml(order.orderId) }</a>
										  </td>
										  <td>
										  	<c:if test="${not empty order.orderCaseId}">
										  		<img width="80" src="${imageService}${order.orderCasePicPath}" />
										  	</c:if>
										  	<c:if test="${empty order.orderCaseId}">
										  		
										  	</c:if>
										  </td>
										  <td>${fn:escapeXml(order.orderShopName) }</td>								  
										  <td>${fn:escapeXml(order.orderShopPhone) }</td>
										  <td>${fn:escapeXml(order.orderMoney) }</td>
										  <td>${fn:escapeXml(order.orderHasPayMoney) }</td>
										  <td>${fn:escapeXml(order.orderFailsPayMoney) }</td>
										  <td>
										  	<c:if test="${order.orderUserStatus == 1}">
										  		<c:if test="${order.orderMoneyStatus == 2 or order.orderMoneyStatus == 3}">
											  		<c:if test="${not empty order.orderThisMoney and order.orderThisMoney != '0.00'  }">
											  		<a class="" href="javascript:userPayment('${order.orderId }','${order.orderMoney }','${order.orderHasPayMoney }','${order.orderFailsPayMoney }','${order.orderThisMoney }');" style="cursor:pointer;">付款</a>
											  		<br>
											  		</c:if>
											  	</c:if>
											  	<c:if test="${order.orderMoneyStatus == 2}">
											  		<a href="javascript:deletedOrder('${order.orderId }');">删除</a>
											  	</c:if>
										  		<c:if test="${order.orderMoneyStatus == 3 or order.orderMoneyStatus == 4}">
											  		<a class="sz_refund"  href="javascript:userApplyRefund('${order.orderId }');" style="cursor:pointer; margin-left:20px;">申请退款</a><br>
											  	</c:if>
										      	<c:if test="${order.orderMoneyStatus == 4}">
											  		<a class="" href="javascript:editStatus('${order.orderId }');" style="cursor:pointer; margin-left:20px;">确认完成</a>
											  	</c:if>
										  	</c:if>
										  	<c:if test="${order.orderUserStatus == 2 and order.orderShopStatus == 1}">
										  		退款中
										  	</c:if>
										  	<c:if test="${order.orderUserStatus == 2 and order.orderShopStatus == 2}">
										  		<a class="sz_refund"  href="javascript:userConfirmRefund('${order.orderId }');" style="cursor:pointer; margin-left:20px;">退款完成</a><br>
										  	</c:if>
										  	<%-- <c:if test="${order.orderUserStatus == 2}">
										  		<a class="" href="javascript:userConfirmRefund('${order.orderId }');" style="cursor:pointer; margin-left:20px;">退款成功</a>
										  	</c:if> --%>
										  </td>
										</tr>
								</c:forEach>
							</c:if>
							</tbody>
							</table>
						</div>
						<div class="clearfix"> </div>
					</div>
					<br>
					<!--page-->
					 <%@ include file="/share/pageTwo.jsp" %>
					<!--end page-->
			    </div>
		    </div>
		</div>
		<!-- /Product-Details-page -->
		<!--付款-->
		<!--付款比例-->
		<div class="contact-bottom-grids" style="display:none;position: fixed;z-index: 99;margin:auto;top: 0;left: 0;right:0;bottom:0;width: 400px;height:400px;background: wheat;border: 1px solid rgb(255, 116, 0);">
			<div class="contact-bottom-grid-right" style="float: none;margin: 0 auto;width: 90%;">
				<h3>Order This Money <span class="close" style="float: right;margin-top: -20px; cursor:pointer;"><img src="${root}/images/010.gif"></span></h3>
				<%-- <form id="userPaymentForm" action="${root }/control/order/orderItemController/userPayment.do" method="post"> --%>
					<div class="text">
						<div class="text-fild-register">
							<span style="font-weight: bold;">Order Number:</span>
							<input name="orderId" type="text" id="orderId" class="l_input" readonly="readonly" style="width:200px;background: none;border: 0;" value="" >
							<div class="Validform_checktip"></div>
						</div>
						<div class="clearfix"> </div>
					</div>
					<div class="text">
						<div class="text-fild-register">
							<span style="font-weight: bold;">Order Money:</span>
							<input name="orderMoney" type="text" id="orderMoney" class="l_input" readonly="readonly" style="width:100px;background: none;border: 0;" value="" >
							<div class="Validform_checktip"></div>
						</div>
						<div class="clearfix"> </div>
					</div>
					<div class="text">
						<div class="text-fild-register">
							<span style="font-weight: bold;">Order orderHasPayMoney:</span>
							<input name="orderHasPayMoney" type="text" id="orderHasPayMoney" class="l_input" readonly="readonly" style="width:100px;background: none;border: 0;" value="" >
							<div class="Validform_checktip"></div>
						</div>
						<div class="clearfix"> </div>
					</div>
					<div class="text">
						<div class="text-fild-register">
							<span style="font-weight: bold;">Order orderFailsPayMoney:</span>
							<input name="orderFailsPayMoney" type="text" id="orderFailsPayMoney" class="l_input" readonly="readonly" style="width:100px;background: none;border: 0;" value="" >
							<div class="Validform_checktip"></div>
						</div>
						<div class="clearfix"> </div>
					</div>
					<div class="text">
						<div class="text-fild-register">
							<span style="font-weight: bold;">Order orderThisMoney:</span>
							<input name="orderThisMoney" type="text" id="orderThisMoney" class="l_input" readonly="readonly" style="width:100px;background: none;border: 0;" maxlength="7" onblur="checkValue();" dataType="/^\d{1,4}(\.\d{1,2})?$/" nullmsg="Please fill in the moeny!" errormsg="The largest money of not more than 9999!">
							<div class="Validform_checktip"></div>
						</div>
						<div class="clearfix"> </div>
					</div>
					<form action="${root }/control/ec/expressCheckoutController/doEC.do" method="post">
						 <table style="display: none;">
	                        <tr><td>物品名称:</td><td><input type="text" name="L_PAYMENTREQUEST_0_NAME0" value="Order"></input></td></tr>
	                        <tr><td>物品编号: </td><td><input id="orderNumber" type="text" name="L_PAYMENTREQUEST_0_NUMBER0" value="" ></input></td></tr>
	                        <tr><td>物品说明:</td><td><input type="text" name="L_PAYMENTREQUEST_0_DESC0" value="Pay the order"></input></td></tr>
	                        <tr><td>价格:</td><td><input id="itemAmt" type="text" name="PAYMENTREQUEST_0_ITEMAMT" value="" readonly></input></td></tr>
	                        <tr><td>用户承担的交易总费用:</td><td><input id="allAmt" type="text" name="PAYMENTREQUEST_0_AMT" value="" readonly></input></td></tr>
	                        <tr><td>
	                        <%-- <input type="hidden" name="LOGOIMG" value="${root }img/logo.jpg"></input></td></tr> --%>
	                        <tr><td>Currency Code:</td><td>
	                        <select id="currencyCodeType" name="currencyCodeType">
								<option selected value="USD">USD</option>
								<option value="BRL">BRL</option>
								<option value="CAD">CAD</option>
								<option value="CZK">CZK</option>
								<option value="DKK">DKK</option>
								<option value="EUR">EUR</option>
								<option value="HKD">HKD</option>
								<option value="HUF">HUF</option>
								<option value="ILS">ILS</option>
								<option value="JPY">JPY</option>
								<option value="NOK">NOK</option>
								<option value="MXN">MXN</option>
								<option value="NZD">NZD</option>
								<option value="PHP">PHP</option>
								<option value="PLN">PLN</option>
								<option value="GBP">GBP</option>
								<option value="SGD">SGD</option>
								<option value="SEK">SEK</option>
								<option value="CHF">CHF</option>
								<option value="TWD">TWD</option>
								<option value="THB">THB</option>
								<option value="TRY">TRY</option>
	                        </select>
	                        <br></td></tr>
	                        <tr><td>Payment Type: </td><td>
	                        	<select>
	                               <option value="Sale">Sale</option>
	                               <option value="Authorization">Authorization</option>
	                               <option value="Order">Order</option>
	                             </select><br>
	                            </td>
	                        </tr>
						</table>
						<input  style="margin:10px 0 20px;float: right;" type="image" src="https://www.paypalobjects.com/webstatic/en_US/i/buttons/checkout-logo-large.png" alt="Check out with PayPal"/>
					</form>
					<!-- <input style="margin:0 0 10px;float: right;" type="submit" value="Send"> -->
					<span id="msgdemo" style="margin-left:30px;"></span>
				<!-- </form> -->
			</div>
			<div class="clearfix"> </div>
		</div>
		<!--end 付款比例-->
		<script type="text/javascript">
			function checkValue(){
				var value = parseFloat(document.getElementById('orderThisMoney').value);
				var failValue = parseFloat(document.getElementById('orderFailsPayMoney').value);
				if(value > failValue){
					$('#orderThisMoney').val('');
					$('#orderThisMoney').next().html("<font style='color:red;'>The payable amount cannot be greater than the amount not paid!</font>");
				}
			}
		</script>
		<!--end 付款-->
		<!--退款-->
		<div class="contact-bottom" style="display:none;position: fixed;z-index: 99;margin:auto;top: 0;left: 0;right:0;bottom:0;width: 600px;height:500px;background: rgb(255, 245, 226);border: 1px solid rgb(255, 116, 0);">
			<div class="contact-bottom-grid-right" style="float: none;margin: 0 auto;width: 90%;">
				<h3>退款申请 <span class="close" style="float: right;margin-top: -20px; cursor:pointer;"><img src="${root}/images/010.gif"></span></h3>
				<form>
					<div class="msg-fild">
						<span>总金额:</span>
						<input type="text" style="padding: 0.4em;" class="text" value="80000">
					</div>
					<div class="msg-fild">
							<span>已付金额:</span>
							<input type="text" style="padding: 0.4em;" class="text" value="30000">
					</div>
					<div class="msg-fild">
							<span>退款金额:</span>
							<input type="text" style="padding: 0.4em;" class="text">
					</div>
					<input style="margin:0 0 10px;float: right;" type="submit" value="提交申请">
				</form>
			</div>
			<div class="clearfix"> </div>
		</div>
		<!--end 退款-->
		<!-- 付款/退款 -->
		<script>
			jQuery(document).ready(function($){
								
			   /*  $('.sz_refund').click(function(){
					$('.contact-bottom').show();
				});
			
				$('.close').click(function(){
					$('.contact-bottom').hide();
				}); */

			});
		</script>
		<!--end 付款/退款-->
		<!-- footer -->
		<%@ include file="/control/jsp/layout/footer.jsp" %>
</body>
</html>

